home *** CD-ROM | disk | FTP | other *** search
- /* UDP packet tracing
- * Copyright 1991 Phil Karn, KA9Q
- */
- /* Mods by PA0GRI */
- #include <stdio.h>
- #include "global.h"
- #include "config.h"
- #include "mbuf.h"
- #include "netuser.h"
- #include "internet.h"
- #include "udp.h"
- #include "ip.h"
- #include "socket.h"
- #include "trace.h"
-
- #ifdef MONITOR
- void rwho_dump __ARGS((FILE *fp,struct mbuf **bpp,int mon));
- #else
- void rwho_dump __ARGS((FILE *fp,struct mbuf **bpp));
- #endif
-
- /* Dump a UDP header */
- void
- #ifdef MONITOR
- udp_dump(fp,bpp,source,dest,check,mon)
- #else
- udp_dump(fp,bpp,source,dest,check)
- #endif
- FILE *fp;
- struct mbuf **bpp;
- int32 source,dest;
- int check; /* If 0, bypass checksum verify */
- #ifdef MONITOR
- int mon;
- #endif
- {
- struct udp udp;
- struct pseudo_header ph;
- int16 csum;
-
- if(bpp == NULLBUFP || *bpp == NULLBUF)
- return;
-
- #ifdef MONITOR
- if (!mon)
- #endif
- fprintf(fp,"UDP:");
-
- /* Compute checksum */
- ph.source = source;
- ph.dest = dest;
- ph.protocol = UDP_PTCL;
- ph.length = len_p(*bpp);
- if((csum = cksum(&ph,*bpp,ph.length)) == 0)
- check = 0; /* No checksum error */
-
- ntohudp(&udp,bpp);
-
- #ifdef MONITOR
- if (!mon)
- #endif
- fprintf(fp," len %u ",udp.length);
- fprintf(fp,"%u->%u",udp.source,udp.dest);
- #ifdef MONITOR
- if (!mon)
- #endif
- if(udp.length > UDPHDR)
- fprintf(fp," Data %u",udp.length - UDPHDR);
- if(udp.checksum == 0)
- check = 0;
- if(check)
- fprintf(fp," CHECKSUM ERROR (%u)",csum);
-
- #ifdef MONITOR
- if (!mon)
- #endif
- fprintf(fp,"\n");
-
- switch(udp.dest){
- #ifdef RIP
- case IPPORT_RIP:
- #ifdef MONITOR
- rip_dump(fp,bpp,mon);
- #else
- rip_dump(fp,bpp);
- #endif
- break;
- #endif
- case IPPORT_RWHO:
- #ifdef MONITOR
- rwho_dump(fp,bpp,mon);
- #else
- rwho_dump(fp,bpp);
- #endif
- break;
- #ifdef MONITOR
- default:
- if (mon)
- fprintf(fp, "\n");
- #endif
- }
-
- }
-
-